#include"../common/list.h"
#include<string.h>


int is_str_equal(void *s1,void *s2){
    return strncmp((char*)s1,(char*)s2,20);    
}

void show_str(void* str){
    printf("%s\n",str);
}

void show_list(list_node head){
    iter_list(head,show_str);
}

int main(){

    list_node list=create_list();
    char * s1 = "chengke";
    char * s2 = "machangfeng";
    char * s3 = "yinzhaoheng";
    char * s4 = "mabohong";

    printf("1\n");
    list=add_node(list,s1);
    show_list(list);
    
    printf("2\n");
    list=add_node(list,s2);
    show_list(list);
    
    printf("3\n");
    list=add_node(list,s3);
    show_list(list);

    printf("4\n");
    list=add_node(list,s4);
    show_list(list);

    printf("%d\n",find_node(list,s1,is_str_equal));
    printf("%d\n",find_node(list,s2,is_str_equal));
    printf("%d\n",find_node(list,s3,is_str_equal));
    printf("%d\n",find_node(list,s4,is_str_equal));

    list=delete_node(list,0);
    show_list(list);

    list=delete_node(list,1);
    show_list(list);

    list=delete_node(list,1);
    show_list(list);
    return 0;
}